home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / network / ka9q / ka9q_src.arc / ARP.H < prev    next >
C/C++ Source or Header  |  1988-07-28  |  3KB  |  83 lines

  1. /* cat > arp.h << '\Rogue\Monster\' */
  2. /* Size of ARP hash table */
  3. #define    ARPSIZE    17
  4.  
  5. /* Lifetime of a valid ARP entry */
  6. #define    ARPLIFE        900    /* 15 minutes */
  7. /* Lifetime of a pending ARP entry */
  8. #define    PENDTIME    15    /* 15 seconds */
  9.  
  10. /* ARP definitions (see RFC 826) */
  11.  
  12. /* Address size definitions */
  13. #define    IPALEN    4        /* Length in bytes of an IP address */
  14. #define    MAXHWALEN    255    /* Maximum length of a hardware address */
  15.  
  16. /* ARP opcodes */
  17. #define    ARP_REQUEST    1
  18. #define    ARP_REPLY    2
  19.  
  20. /* Hardware types */
  21. #define    ARP_ETHER    1    /* Assigned to 10 megabit Ethernet */
  22. #define    ARP_EETHER    2    /* Assigned to experimental Ethernet */
  23. #define    ARP_AX25    3    /* Assigned to AX.25 Level 2 */
  24. #define    ARP_PRONET    4    /* Assigned to PROnet token ring */
  25. #define    ARP_CHAOS    5    /* Assigned to Chaosnet */
  26. #define ARP_NETROM    6    /* Fake netrom arp type */
  27. #define    ARP_ARCNET    7
  28. #define    ARP_APPLETALK    8
  29. extern char *arptypes[];    /* Type fields in ASCII, defined in arpcmd */
  30. #define    NHWTYPES 9
  31.  
  32. /* Table of hardware types known to ARP */
  33. struct arp_type {
  34.     int16 hwalen;        /* Hardware length */
  35.     int16 iptype;        /* Hardware type field for IP */
  36.     int16 arptype;        /* Hardware type field for ARP */
  37.     char *bdcst;        /* Hardware broadcast address */
  38.     int (*format)();    /* Function that formats addresses */
  39.     int (*scan)();        /* Reverse of format */
  40. };
  41. extern struct arp_type arp_type[];
  42. #define    NULLATYPE    (struct arp_type *)0
  43.  
  44. /* Format of an ARP request or reply packet. From p. 3 */
  45. struct arp {
  46.     int16 hardware;            /* Hardware type */
  47.     int16 protocol;            /* Protocol type */
  48.     char hwalen;            /* Hardware address length, bytes */
  49.     char pralen;            /* Length of protocol address */
  50.     int16 opcode;            /* ARP opcode (request/reply) */
  51.     char shwaddr[MAXHWALEN];    /* Sender hardware address field */
  52.     int32 sprotaddr;        /* Sender Protocol address field */
  53.     char thwaddr[MAXHWALEN];    /* Target hardware address field */
  54.     int32 tprotaddr;        /* Target protocol address field */
  55. };
  56.         
  57. /* Format of ARP table */
  58. struct arp_tab {
  59.     struct arp_tab *next;    /* Doubly-linked list pointers */
  60.     struct arp_tab *prev;    
  61.     int32 ip_addr;        /* IP Address, host order */
  62.     int16 hardware;        /* Hardware type */
  63.     char *hw_addr;        /* Hardware address */
  64.     char state;        /* (In)complete */
  65. #define    ARP_PENDING    0
  66. #define    ARP_VALID    1
  67.     struct timer timer;    /* Time until aging this entry */
  68.     struct mbuf *pending;    /* Queue of datagrams awaiting resolution */
  69. };
  70. struct arp_tab *arp_lookup(),*arp_add();
  71. #define    NULLARP    (struct arp_tab *)0
  72. extern struct arp_tab *arp_tab[];
  73.  
  74. struct arp_stat {
  75.     unsigned recv;        /* Total number of ARP packets received */
  76.     unsigned badtype;    /* Incoming requests for unsupported hardware */
  77.     unsigned badlen;    /* Incoming length field(s) didn't match types */
  78.     unsigned badaddr;    /* Bogus incoming addresses */
  79.     unsigned inreq;        /* Incoming requests for us */
  80.     unsigned replies;    /* Replies sent */
  81.     unsigned outreq;    /* Outoging requests sent */
  82. };
  83.